﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Jumpton.SFA.Server.BusinessRule.MasterData;
using Jumpton.SFA.Server.Entity;

public partial class Customer_Product_List : PageBase
{
    private const string RESPONSE_MAINTAIN_PAGE = "Customer_Product_List_Maintain.aspx";
    private const string RESPONSE_ITEM_PAGE = "Customer_Product_List_Item.aspx?listID=";
    private const string RESPONSE_CUSTOMER_PAGE = "Customer_Product_List_Customer.aspx?listID=";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BindGrid();
        }
    }

    private void BindGrid()
    {
        GridPager1.DataSource = new CustomerProductListManager().GetCourseTable(this.MyStateManager.DomainID);
        GridPager1.GridView = gvChannelType;
        GridPager1.BindData();
        GridPager1.Visible = gvChannelType.Rows.Count > 0;
      
    }

    protected void btnNew_Click(object sender, EventArgs e)
    {
        Response.Redirect(RESPONSE_MAINTAIN_PAGE);
    }

    protected void gvChannelType_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string strListID = e.CommandArgument.ToString();
        if (e.CommandName == "AddProduct")
        {
            Response.Redirect(RESPONSE_ITEM_PAGE + strListID);
        }
        else if(e.CommandName=="AddCustomer")
        {
            Response.Redirect(RESPONSE_CUSTOMER_PAGE + strListID);
        }
    }

    protected void gvChannelType_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvChannelType.PageIndex = e.NewPageIndex;
        BindGrid();
    }
}
